import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Bala here.
 * 
 * @author (Fco Fernando Gosch Acosta) 
 * @version (1.0)
 */
public class Bala extends Pistola
{
   
    /**
     * Bala Constructor para la clase bala
     *
     * @param la rotacion del arma
     */
    public Bala(int rot)
    {
        super(0);
        setRotation(rot);
    }
    
    /**
     * Act - do whatever the Bala wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        move(2);
        Pulido p = (Pulido) getOneIntersectingObject(Pulido.class);
        Grande g = (Grande) getOneIntersectingObject(Grande.class);
        Metal m = (Metal) getOneIntersectingObject(Metal.class);
        Pequenio pe = (Pequenio) getOneIntersectingObject(Pequenio.class);
        Tierra t = (Tierra) getOneIntersectingObject(Tierra.class);
        Sol s = (Sol) getOneIntersectingObject(Sol.class);
        
        if(p!=null){
            p.reciveDanio((danioBala / 2 ));
            getWorld().removeObject(this);
        }
        
        else if(g!=null){
            g.reciveDanio((danioBala));
            getWorld().removeObject(this);
        }
        
        else if(m!=null){
           m.reciveDanio(danioBala * 1);
           getWorld().removeObject(this);
        }
        
        else if(pe!=null){
            pe.reciveDanio(danioBala * 2);
            getWorld().removeObject(this);
        }
        
        else if(alBorde())
            getWorld().removeObject(this); 
        
        else if(t!=null){            
            getWorld().removeObject(this);
        }
        
        else if(s!=null){            
            getWorld().removeObject(this);
        }
    }    
}
